<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in">
      <div class="cornerComment-in-title">
        <span>【{{studentName}}】评测总览【点击评测项查看历史曲线图】</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <div class="food-body" v-if="tableList.length">
          <div class="food-list" v-for="(item,index) in tableList" :key="index">
            <h3 class="food-list-title">{{ item.name }}</h3>
            <el-table
                :data="item.list"
                size="mini"
                stripe
            @row-click="rowClick">
              <el-table-column
                  prop="name"
                  label="评测项"
                  width="100"
                  align="center">
              </el-table-column>
              <el-table-column
                  label="分值"
                  width="100"
                  align="center">
                <template slot-scope="scope">
                  <span v-if="JSON.stringify(scope.row.log)!=='[]'">{{scope.row.log.score }}{{scope.row.type==1?'秒':'次'}}</span>
                  <span v-else>
                    未评测
                  </span>
                </template>
              </el-table-column>
              <el-table-column
                  label="年段均值"
                  width="80"
                  align="center">
                <template slot-scope="scope">
                  {{ scope.row.avg}}{{scope.row.type==1?'秒':'次'}}
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <div v-else class="not-data-point">
          未找到当天相关点评内容
        </div>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click.native="closePOpup" size="small">取消</el-button>
        <downexcel type="evaluatingStudentPoint" :option="{student_id: this.studentId}" :excelName="this.studentName"></downexcel>
      </div>
    </div>
    <echartsline :visible.sync="echartVisible" :studentId="studentId" :studentName="studentName" :optionData="optionData"></echartsline>
  </div>
</template>

<script>
import {assessDetailAll} from '@/api/admin/evaluating'
import echartsline from "./echartsline";
export default {
  props: ['visible', 'studentId', 'studentName'], // recruitmentType examine 审核
  components: {echartsline},
  data() {
    return {
      dialogVisible: false,
      tableList: [],
      echartVisible: false,
      optionData: null
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        this.getWeekFood()
      }else{
        this.tableList = []
      }
    }
  },
  created() {
  },
  methods: {
    getWeekFood() {
      assessDetailAll({student_id: this.studentId}).then(res => {
        let list = []
        for(let item of res.list){
          if(item.list.length){
            list.push(item)
          }
        }
        this.tableList = this.getJson(list)
      })
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
    rowClick(row, column, event){
      console.log('row:', row, column, event)
      this.optionData = JSON.parse(JSON.stringify(row))
      this.echartVisible = true
    }
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  /*width: 950px;*/
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px;
  flex: 1;
  max-height: 650px;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.resruitment-title {
  padding: 5px 0;
  border-bottom: 2px solid #abd3f3;
  margin-bottom: 20px;
}

.el-radio {
  margin-right: 20px;
}

.jobTime {
  display: flex;
  align-items: center;
}

.jobTime span {
  padding: 0 10px;
}

.food-body {
  display: flex;
}

.food-list {
  border: 1px solid #cacaca;
  margin-right: 5px;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 2px 2px #c5c5c5;
}

.food-list:last-child {
  margin-right: 0;
}

.food-list-title {
  background: #1b8de5;
  height: 30px;
  line-height: 30px;
  text-align: center;
  color: #fff;
}
.not-data-point{
  width:400px;
  height: 400px;
  line-height: 400px;
  text-align: center;
  color: #999;
}
</style>
